//
//  ZXBaseTool.m
//  ZXOCWeiBo
//
//  Created by mac on 15/12/9.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZXBaseTool.h"
#import "ZXHttpTool.h"

@implementation ZXBaseTool
+(void)getWithUrl:(NSString *)url params:(id)params resultClass:(Class )resultClass success:(void (^)(id  result))success failure:(void(^)(NSError *error))failure
{
    [ZXHttpTool GET:url params:[params keyValues] success:^(id responseObject) {
//        ZXLog(@"--------%@",responseObject);
 id result =  [resultClass objectWithKeyValues:responseObject];
        if (success) {
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}
/**
 *  post请求
 *
 *  @param url         url
 *  @param params      一定要模型
 *  @param resultClass 返回结果模型
 *  @param success     成功回调
 *  @param failure     失败回调
 */
+(void)postWithUrl:(NSString *)url params:(id)params resultClass:(Class )resultClass success:(void (^)(id  result))success failure:(void(^)(NSError *error))failure
{
    [ZXHttpTool POST:url params:[params keyValues] success:^(id responseObject) {
        id result =  [resultClass objectWithKeyValues:responseObject];
        if (success) {
            success(result);
        }
    } failure:^(NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}
@end
